home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
MPW_TOOL
/
TOOLS
/
TOOLS_WI
/
ICON_8
/
MEMMON_F
/
MMAED.C
< prev
next >
Wrap
Text File
|
1990-03-02
|
5KB
|
209 lines
/*
* mmaed.c: graphics driver for AED 1024.
*
* The AED is a 1024 x 768 x 8 color display with an 8+8+8 bit lookup table.
*
* For reasons of speed, this driver writes all blocks one pixel high
* using a runlength encoding. Hardware zoom (vertically only) is used
* to make the display look reasonable. This all works well and does
* speed things up quit a bit, but it means we can't write any text,
* so there's no legend on the display.
*/
#include <varargs.h>
#include "memmon.h"
hidden novalue aedcmd Params((/*varargs*/));
#define VSize 768 /* vertical screen size */
#define HSize 1024 /* horizontal screen size */
#define EndRun() if(runaddr)putchar(runaddr=0) /* end a run of pixels */
static runaddr = 0; /* curr addr if pixel run in progress */
/*
* devsetup() - set globals to device-dependent values.
*/
novalue devsetup()
{
granularity = 4;
width = HSize;
height = VSize;
textrow = 0; /* no legend */
textsep = 0; /* so no separating line */
memrow = 16;
}
/*
* devinit() - initialize for graphics output.
*/
novalue devinit()
{
static char obuf[BUFSIZ]; /* small buffer for smoother output */
if (height != VSize || width != HSize || textrow > 0) {
fprintf(stderr, "%s: -h, -w, -L ignored\n", progname);
height = VSize;
width = HSize;
textrow = 0;
}
if (memrow > 16) {
fprintf(stderr, "%s: -M limited to 16\n", progname);
memrow = 16; /* hardware limit */
}
litout(); /* set literal output mode if a tty */
setbuf(stdout, obuf); /* set small, local buffer */
fputs("\033SEN18D88", stdout); /* set encoding mode to binary */
aedcmd("gii", 0, 767); /* set normal window boundaries */
aedcmd("4bbbbbb", Unmarked + C_Blink, 0, 0, 0, 20, 20);
/* blink C_Blink with black */
}
/*
* devmap() - load color map into device.
*/
novalue devmap()
{
int i;
EndRun();
aedcmd("Kbb", 0, MapSize);
for (i = 0; i < MapSize; i++) {
putchar(cmap[i].red);
putchar(cmap[i].green);
putchar(cmap[i].blue);
}
}
/*
* devflood(c) - fill screen with color c.
*/
novalue devflood(c)
int c;
{
EndRun();
aedcmd("Ebb", 1, memrow); /* set zoom for y scaling (only!) */
aedcmd("[b", c); /* set background color */
aedcmd("~"); /* erase screen (kills scaling) */
aedcmd("Ebb", 1, memrow); /* reset scaling */
}
/*
* devpaint(start, n, color, b) - paint n pixels in given color.
* If b >= 0, the last pixel is to be that color instead (for a border)
*/
novalue devpaint(s, n, c, b)
word s, n;
int c, b;
{
if (runaddr && runaddr != s)
putchar(runaddr = 0);
if (!runaddr) {
aedcmd("Qx", s % HSize, VSize - 1 - s / HSize);
aedcmd("s");
}
runaddr = s + n;
if (b >= 0)
n--;
while (n > 254) {
putchar(254);
putchar(c);
n -= 254;
}
if (n > 0) {
putchar(n);
putchar(c);
}
if (b >= 0) {
putchar(1);
putchar(b);
}
}
/*
* devtext(string, row, col, fgcolr, bgcolr) - don't output text.
* (We can't output any text due to the mode we've put the AED in.)
* (So, with textrow=0, this shouldn't ever be called, but is needed to link.)
*/
/*ARGSUSED*/
novalue devtext(s, r, c, f, b)
char *s;
int r, c, f, b;
{
}
/*
* devsnap() - batch mode snapshot; no action needed here.
*/
novalue devsnap()
{
}
/*
* devflush() - flush output.
*/
novalue devflush()
{
EndRun();
fflush(stdout);
}
/*
* devterm() - terminate graphics.
*/
novalue devterm()
{
EndRun();
aedcmd("Gs", "3DNNN"); /* reset encoding */
aedcmd("\r"); /* exit graphics mode */
}
/*
* aedcmd(s, args) - output command to the AED.
* s is a string specifying the command format a la printf. The first
* character (or two chars if first is '+') are the AED command.
* Additional characters specify formats for outputting additional
* arguments (see below).
*/
/*VARARGS1*/
static novalue aedcmd (s, va_alist)
char *s;
va_dcl
{
va_list ap;
char c;
unsigned int n, x, y;
va_start(ap);
if (putchar(*s++) == '+')
putchar(*s++);
while (c = *s++)
switch (c) { /* Output formats for add'l args: */
case 'b': /* b - single byte unaltered */
case 'c': /* c - single char unaltered */
n = va_arg(ap, int);
putchar(n);
break;
case 'i': /* i - 16-bit integer as two bytes */
n = va_arg(ap, int);
putchar(n>>8);
putchar(n);
break;
case 's': /* s - string terminated by '\0' */
fputs(va_arg(ap, char*), stdout);
break;
case 'x': /* x - two args give x and y coords */
x = va_arg(ap, int);
y = va_arg(ap, int);
putchar(((x >> 4) & 0xF0) | (y >> 8));
putchar(x);
putchar(y);
break;
default: /* unrecognized - just echoed */
putchar(c);
}
va_end(ap);
}